//
//  KRWebController.m
//  cookBook
//
//  Created by kuroken on 16/2/4.
//  Copyright © 2016年 kuroken. All rights reserved.
//

#define MAS_SHORTHAND

#import "KRWebController.h"
#import <Masonry.h>
#import <SVProgressHUD.h>

@interface KRWebController () <UIWebViewDelegate>
/** UIWebView */
@property (nonatomic, weak) UIWebView *webView;
@end

@implementation KRWebController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [SVProgressHUD show];

    UIWebView *webView = [[UIWebView alloc] init];
    webView.delegate = self;
    [self.view addSubview:webView];
    [webView makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.and.right.and.bottom.equalTo(self.view);
    }];
    self.webView = webView;

    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
}

- (void)dealloc
{
    NSLog(@"%s", __func__);
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [SVProgressHUD dismiss];
    self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
